package com.controller;

import com.util.HotUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import living.com.result.ApiResult;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * <P>
 *     热度控制器
 * </P>
 * @author 大忽悠
 * @create 2022/2/19 13:07
 */
@RequiredArgsConstructor
@RestController
@Api(tags = "热度请求控制")
@RequestMapping("/hot")
public class HotController {
    private final HotUtil hotUtil;
    @ApiOperation("每小时问题请求热度减少值")
    @PostMapping("/issue_hour_reduce_hot")
    public ApiResult<Boolean> ISSUE_HOUR_REDUCE_HOT(@RequestParam@ApiParam("热度减少值") Integer hot)
    {
        hotUtil.setISSUE_HOUR_REDUCE_HOT(hot);
       return ApiResult.success(true);
    }

    @ApiOperation("问题点赞热度增加值")
    @PostMapping("/issue_like_hot_add")
    public ApiResult<Boolean> ISSUE_LIKE_HOT_ADD(@RequestParam@ApiParam("热度增加值") Integer hot)
    {
        hotUtil.setISSUE_LIKE_HOT_ADD(hot);
        return ApiResult.success(true);
    }

    @ApiOperation("每小时标签请求热度减少值")
    @PostMapping("/label_hour_reduce_hot")
    public ApiResult<Boolean> LABEL_HOUR_REDUCE_HOT(@RequestParam@ApiParam("热度减少值") Integer hot)
    {
        hotUtil.setLABEL_HOUR_REDUCE_HOT(hot);
        return ApiResult.success(true);
    }

    @ApiOperation("标签点赞热度增加值")
    @PostMapping("/label_like_hot_add")
    public ApiResult<Boolean> LABEL_LIKE_HOT_ADD(@RequestParam@ApiParam("热度增加值") Integer hot)
    {
        hotUtil.setLABEL_LIKE_HOT_ADD(hot);
        return ApiResult.success(true);
    }

    @ApiOperation("是否开启热度自动减少功能")
    @PostMapping("/is_auto_hot_reduce")
    public ApiResult<Boolean> IS_AUTO_HOT_REDUCE(@RequestParam@ApiParam("是否开启热度自动减少,1开启,0关闭")Integer isAutorReduceHot)
    {
        hotUtil.setAutoHotReduce(isAutorReduceHot==1?true:false);
        return ApiResult.success(true);
    }
}


